#include "Authentification.h"

Authentification::Authentification(): QWidget(){

        QFont font("Mainandra GD",13);

        lPseudo= new QLabel("Login ");
        lPseudo->setFont(font);
        pseudo= new QLineEdit;
        lpassWord= new QLabel("passWord ");
        lpassWord->setFont(font);
        passWord= new QLineEdit();
        passWord->setEchoMode(QLineEdit::Password);
        ok= new QPushButton("S'authentifier");
        quitter= new QPushButton("Quitter");

        QGridLayout* gLayout= new QGridLayout;
        gLayout->addWidget(lPseudo,1,1);
        gLayout->addWidget(pseudo,1,2);
        gLayout->addWidget(lpassWord,2,1);
        gLayout->addWidget(passWord,2,2);
        QHBoxLayout* okLayout= new QHBoxLayout;
        okLayout->setAlignment(Qt::AlignRight);
        okLayout->addWidget(ok);
        okLayout->addWidget(quitter);

        QVBoxLayout* layout= new QVBoxLayout;
        layout->addLayout(gLayout);
        layout->addLayout(okLayout);

        this->setLayout(layout);

    // signals et slots


}

QPushButton* Authentification::getQuitter(){
    return quitter;
}

QPushButton* Authentification::getOk(){
    return ok;
}

void Authentification::authentifierAdmin(){
    if(pseudo->text()=="admin" && passWord->text()=="admin"){
        QMessageBox::information(this, "Bienvenu", "Authentification reussi");
        espaceAdmin= new EspaceAdmin;
        espaceAdmin->show();
        this->nativeParentWidget()->close();
    }
    else
        QMessageBox::critical(this, "Error", "Authentification failed");
}
void Authentification::authentifierGestion(){
    if(pseudo->text()=="gestion" && passWord->text()=="gestion"){
        QMessageBox::information(this, "Bienvenu", "Authentification reussi");
        espaceGestionClient= new EspaceGestionClient;
        espaceGestionClient->show();
        this->nativeParentWidget()->close();
    }
    else
        QMessageBox::critical(this, "Error", "Authentification failed");
}
